<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: August 22, 2001-->
<!--
$Id: MachineDel.php,v 1.4 2001/11/02 19:06:20 eugenem Exp eugenem $
$Header: /export/home/eugenem/public_html/ComplianceReports/RCS/MachineDel.php,v 1.4 2001/11/02 19:06:20 eugenem Exp eugenem $
$Log: MachineDel.php,v $
Revision 1.4  2001/11/02 19:06:20  eugenem
Moved HTTP_*_VARS processing to dbc.inc

Revision 1.3  2001/11/02 14:57:47  eugenem
Moved database connect statements to a separate file.

Revision 1.2  2001/09/11 15:51:47  eugenem
Sort machine list alphabetically.

Revision 1.1  2001/08/22 19:31:10  eugenem
Initial revision

-->

<html>
<head>
<title>Radiological Equipment Database</title>
<meta name="author" content="Eugene Mah">
<link rev="made" href="mailto:eugenem@ix.netcom.com">
<link rev="home" href="http://home.netcom.com/~eugenem/">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="Reply-to" content="eugenem@ix.netcom.com">
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))'>
<?PHP
require('functions.inc');
require('dbc.inc');

?>
</head>

<body>
<h1>Radiological Equipment Database</h1>
<h2>Delete a unit</h2>
<?PHP
if (isset($MachID)) {
  $query = "update Machines set Status=\"$Status\",RemoveDate=CURDATE(),Notes=concat(Notes,\"\n\",\"$Note\") where MachineID=$MachID";
  $result = mysql_query($query)
    or die("<p>Unable to execute query: $query<br />" . mysql_error() . "</p>");
  if ($result) echo "<p>Status of machine $MachID updated</p>\n";
  $query = "SELECT count(*) AS n FROM Tubes WHERE MachineID=$MachID";
  $result = mysql_query($query)
    or die("<p>Unable to execute query: $query<br />" . mysql_error() . "</p>");
  $row = mysql_fetch_row($result);
  if ($row[0] > 0) {
    $query = "update Tubes set Status=\"$Status\",RemoveDate=CURDATE() where MachineID=$MachID";
    $result = mysql_query($query)
      or die("<p>Unable to execute query: $query<br />" . mysql_error() . "</p>");
    if ($result) echo "<p>Status of tubes for machine $MachID updated</p>\n";
  }
}
?>
<form action="MachineDel.php" method="POST">
<p>Select a machine to deactivate:
<?PHP
$machines = mysql_query("select MachineID,Description from Machines where Status=\"Active\" order by Description");
echo listbox_field($machines,"MachID","");
?>
</p>
<p>Set status of machine:
    <select name="Status" size="1">
        <option value="Active">Active</option>
        <option value="Inactive" selected="selected">Inactive</option>
        <option value="Removed">Removed</option>
    </select>
</p>
<p><textarea name="Note" rows="3" cols="70">Enter a note</textarea></p>
<p><input type="SUBMIT" value="Deactivate"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
<?PHP mysql_close() ?>
</body>
</html>
